1
2 import java.sql.Connection;
3 import java.sql.DriverManager;
4 import java.sql.Statement;

5
6 /*
7  * To change
this license header, choose License Headers in Project Properties.
8  * To change
this template file, choose Tools | Templates
9  * and open the template
in the editor.
10  */
11
12 /**
13  *
14  * @author MY LAPI
15  */

16 public
class Accgernerator extends javax.swing.JFrame {
17
18     
/**
19      * Creates
new form Accgernerator
20      */

21     
public Accgernerator(int uid) {
22         initComponents();
23         
try{
24             Class.forName(
"com.mysql.jdbc.Driver").newInstance();
25             Connection cn=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/bank","root","");
26             
27             String accno=
"3499230500"+uid;
28             jLabel5.setText(accno);
29             Statement smt=cn.createStatement();
30             String p=
"update user set accno='"+accno+"' where uid='"+uid+"' ";
31            smt.executeUpdate(p);
32     
33         }
catch(Exception e){}
34     }
35
36     
private Accgernerator() {
37         
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
38     }
39
40     
/**
41      * This method
is called from within the constructor to initialize the form.
42      * WARNING: Do NOT modify
this code. The content of this method is always
43      * regenerated
by the Form Editor.
44      */

45     @SuppressWarnings(
"unchecked")
46     
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
47     
private void initComponents() {
48
49         jLabel1 =
new javax.swing.JLabel();
50         jLabel2 =
new javax.swing.JLabel();
51         jLabel3 =
new javax.swing.JLabel();
52         jLabel4 =
new javax.swing.JLabel();
53         jTextField1 =
new javax.swing.JTextField();
54         jButton1 =
new javax.swing.JButton();
55         jButton2 =
new javax.swing.JButton();
56         jLabel5 =
new javax.swing.JLabel();
57         jLabel6 =
new javax.swing.JLabel();
58
59         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
60
61         jLabel1.setFont(
new java.awt.Font("Arial Unicode MS", 0, 18)); // NOI18N
62         jLabel1.setText(
"Account Number & ATM Generate");
63
64         jLabel2.setFont(
new java.awt.Font("Arial Unicode MS", 0, 14)); // NOI18N
65         jLabel2.setText(
"Account No");
66
67         jLabel3.setFont(
new java.awt.Font("Arial Unicode MS", 1, 14)); // NOI18N
68
69         jLabel4.setFont(
new java.awt.Font("Arial Unicode MS", 0, 14)); // NOI18N
70         jLabel4.setText(
"ATM Card No");
71
72         jTextField1.setFont(
new java.awt.Font("Arial Unicode MS", 0, 14)); // NOI18N
73
74         jButton1.setFont(
new java.awt.Font("Arial Unicode MS", 0, 18)); // NOI18N
75         jButton1.setText(
"Home");
76         jButton1.addActionListener(
new java.awt.event.ActionListener() {
77             
public void actionPerformed(java.awt.event.ActionEvent evt) {
78                 jButton1ActionPerformed(evt);
79             }
80         });
81
82         jButton2.setFont(
new java.awt.Font("Arial Unicode MS", 0, 18)); // NOI18N
83         jButton2.setText(
"UPDATE");
84         jButton2.addActionListener(
new java.awt.event.ActionListener() {
85             
public void actionPerformed(java.awt.event.ActionEvent evt) {
86                 jButton2ActionPerformed(evt);
87             }
88         });
89
90         jLabel5.setFont(
new java.awt.Font("Arial Unicode MS", 0, 18)); // NOI18N
91
92         javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
93         getContentPane().setLayout(layout);
94         layout.setHorizontalGroup(
95             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
96             .addGroup(layout.createSequentialGroup()
97                 .addGap(
56, 56, 56)
98                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
99                     .addComponent(jLabel1)
100                     .addGroup(layout.createSequentialGroup()
101                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
102                             .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE,
86, javax.swing.GroupLayout.PREFERRED_SIZE)
103                             .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE,
96, javax.swing.GroupLayout.PREFERRED_SIZE))
104                         .addGap(
24, 24, 24)
105                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
106                             .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
107                             .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE,
186, Short.MAX_VALUE)
108                             .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
109                 .addContainerGap(
38, Short.MAX_VALUE))
110             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
111                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
112                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
113                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
114                         .addComponent(jButton1)
115                         .addGap(
62, 62, 62)
116                         .addComponent(jButton2)
117                         .addGap(
70, 70, 70))
118                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
119                         .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE,
162, javax.swing.GroupLayout.PREFERRED_SIZE)
120                         .addGap(
51, 51, 51))))
121         );
122         layout.setVerticalGroup(
123             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
124             .addGroup(layout.createSequentialGroup()
125                 .addContainerGap()
126                 .addComponent(jLabel1)
127                 .addGap(
40, 40, 40)
128                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
129                     .addComponent(jLabel2)
130                     .addComponent(jLabel3)
131                     .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE,
23, javax.swing.GroupLayout.PREFERRED_SIZE))
132                 .addGap(
34, 34, 34)
133                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
134                     .addComponent(jLabel4)
135                     .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
136                 .addGap(
18, 18, 18)
137                 .addComponent(jLabel6)
138                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
27, Short.MAX_VALUE)
139                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
140                     .addComponent(jButton2)
141                     .addComponent(jButton1))
142                 .addGap(
30, 30, 30))
143         );
144
145         pack();
146     }
// </editor-fold>//GEN-END:initComponents
147
148     
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
149        
try{
150             Class.forName(
"com.mysql.jdbc.Driver").newInstance();
151             Connection cn=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/bank","root","");
152             
153             String accno= jLabel5.getText();
154            
155             Statement smt=cn.createStatement();
156             String p=
"update user set atm='"+jTextField1.getText()+"' where accno='"+accno+"' ";
157            smt.executeUpdate(p);
158            jTextField1.setText(
"");
159            jLabel6.setText(
"Data Update Successfully");
160     
161         }
catch(Exception e){}
162     }
//GEN-LAST:event_jButton2ActionPerformed
163
164     
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
165                 Accgernerator pb1=
new Accgernerator();
166                 AdminDesh pb2=
new AdminDesh();
167                 pb1.setVisible(
false);
168                 pb2.setVisible(
true);
169                 dispose();
170     }
//GEN-LAST:event_jButton1ActionPerformed
171
172     
/**
173      * @param args the command line arguments
174      */

175     
public static void main(String args[]) {
176         
/* Set the Nimbus look and feel */
177         
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
178         
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
179          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
180          */

181         
try {
182             
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
183                 
if ("Nimbus".equals(info.getName())) {
184                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
185                     
break;
186                 }
187             }
188         }
catch (ClassNotFoundException ex) {
189             java.util.logging.Logger.getLogger(Accgernerator.
class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
190         }
catch (InstantiationException ex) {
191             java.util.logging.Logger.getLogger(Accgernerator.
class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
192         }
catch (IllegalAccessException ex) {
193             java.util.logging.Logger.getLogger(Accgernerator.
class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
194         }
catch (javax.swing.UnsupportedLookAndFeelException ex) {
195             java.util.logging.Logger.getLogger(Accgernerator.
class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
196         }
197         
//</editor-fold>
198
199         
/* Create and display the form */
200         java.awt.EventQueue.invokeLater(
new Runnable() {
201             
public void run() {
202                 
new Accgernerator().setVisible(true);
203             }
204         });
205     }
206
207     
// Variables declaration - do not modify//GEN-BEGIN:variables
208     
private javax.swing.JButton jButton1;
209     
private javax.swing.JButton jButton2;
210     
private javax.swing.JLabel jLabel1;
211     
private javax.swing.JLabel jLabel2;
212     
private javax.swing.JLabel jLabel3;
213     
private javax.swing.JLabel jLabel4;
214     
private javax.swing.JLabel jLabel5;
215     
private javax.swing.JLabel jLabel6;
216     
private javax.swing.JTextField jTextField1;
217     
// End of variables declaration//GEN-END:variables
218 }


Gõ tìm kiếm nhanh...